Skip to content

fix: path when genesis file already exists.#2361

Merged
tac0turtle merged 2 commits intoevstack:mainfrom
adlerjohn:adlerjohn/genesis-file-exists-error
Jun 11, 2025
Merged

fix: path when genesis file already exists.#2361
tac0turtle merged 2 commits intoevstack:mainfrom
adlerjohn:adlerjohn/genesis-file-exists-error

Conversation

@adlerjohn
Copy link
Copy Markdown
Contributor

@adlerjohn adlerjohn commented Jun 10, 2025

Fix incorrect use of homePath for genesis file path.

Summary by CodeRabbit

  • Refactor
    • Improved handling of genesis file paths by consistently using the explicit genesis file location in messages and file operations across multiple components.
  • New Features
    • Added a utility to generate the full path to the genesis file from the home directory.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 10, 2025

Walkthrough

The changes introduce a new utility function to construct the path to the genesis file based on a given home directory. This function is then used in multiple initialization commands to ensure consistent and explicit handling of the genesis file path, replacing previous direct uses of the home directory path.

Changes

File(s) Change Summary
pkg/genesis/io.go Added GenesisPath function to generate the genesis file path from a home directory.
apps/evm/based/cmd/init.go,
apps/evm/single/cmd/init.go,
apps/testapp/cmd/init.go
Updated to use GenesisPath for genesis file operations instead of using the home directory directly.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI_Init_Command
    participant GenesisPkg

    User->>CLI_Init_Command: Run initialization
    CLI_Init_Command->>GenesisPkg: GenesisPath(homePath)
    GenesisPkg-->>CLI_Init_Command: Return genesis file path
    CLI_Init_Command->>GenesisPkg: LoadGenesis(genesisPath)
    GenesisPkg-->>CLI_Init_Command: Genesis data or error
    CLI_Init_Command->>User: Print status/logs using genesisPath
Loading

Poem

In the warren of code, a new path appears,
For genesis files, the direction now clears.
No more guessing where the config may dwell,
A function now guides us, and all is well.
With every init, the rabbits now cheer—
The genesis is found, and the path is clear!
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (1.64.8)

Error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2
Failed executing command with error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@adlerjohn adlerjohn marked this pull request as ready for review June 10, 2025 15:29
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
pkg/genesis/io.go (1)

23-25: Consider using the new GenesisPath function for consistency.

The CreateGenesis function manually constructs the genesis path, but it could use the newly introduced GenesisPath function for consistency.

Apply this diff to use the centralized path construction:

-	configDir := filepath.Join(homePath, "config")
-	genesisPath := filepath.Join(configDir, "genesis.json")
+	genesisPath := GenesisPath(homePath)
+	configDir := filepath.Dir(genesisPath)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f1f28c4 and 1c837bb.

📒 Files selected for processing (4)
  • apps/evm/based/cmd/init.go (1 hunks)
  • apps/evm/single/cmd/init.go (1 hunks)
  • apps/testapp/cmd/init.go (1 hunks)
  • pkg/genesis/io.go (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
apps/evm/based/cmd/init.go (1)
pkg/genesis/io.go (3)
  • GenesisPath (14-17)
  • ErrGenesisExists (11-11)
  • LoadGenesis (54-76)
apps/evm/single/cmd/init.go (1)
pkg/genesis/io.go (3)
  • GenesisPath (14-17)
  • ErrGenesisExists (11-11)
  • LoadGenesis (54-76)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Summary
🔇 Additional comments (6)
pkg/genesis/io.go (1)

13-17: Good addition for centralizing genesis path logic.

The new GenesisPath function properly encapsulates the logic for constructing the genesis file path from a home directory.

apps/testapp/cmd/init.go (3)

65-65: Good fix for explicit genesis file path handling.

Using GenesisPath to get the actual genesis file path instead of using the home directory path directly is the correct approach.


68-68: Correctly fixes the LoadGenesis path parameter.

This change fixes a bug where LoadGenesis was being called with homePath (a directory) instead of the actual genesis file path. According to the LoadGenesis function signature in pkg/genesis/io.go (lines 54-76), it expects a file path, not a directory path.


76-76: Improved user feedback with specific file path.

The printf statement now shows the exact genesis file path instead of just the home directory, providing clearer information to the user.

apps/evm/single/cmd/init.go (1)

65-76: Consistent implementation of genesis path fix.

The changes follow the same pattern as in apps/testapp/cmd/init.go, correctly using the new GenesisPath function to get the actual genesis file path instead of passing the home directory to LoadGenesis. This ensures consistency across all init commands and fixes the path handling bug.

apps/evm/based/cmd/init.go (1)

65-76: Excellent consistency in fixing the genesis path issue.

The implementation mirrors the changes in the other init commands (apps/testapp/cmd/init.go and apps/evm/single/cmd/init.go), ensuring uniform handling of genesis file paths across all initialization commands. This systematic approach fixes the bug where LoadGenesis was incorrectly receiving directory paths instead of file paths.

Copy link
Copy Markdown
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@tac0turtle tac0turtle enabled auto-merge June 10, 2025 20:15
@tac0turtle tac0turtle added this pull request to the merge queue Jun 10, 2025
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 10, 2025

Codecov Report

Attention: Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Project coverage is 69.57%. Comparing base (3d0ec7a) to head (1d0c7d9).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
pkg/genesis/io.go 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2361      +/-   ##
==========================================
- Coverage   69.64%   69.57%   -0.07%     
==========================================
  Files          64       64              
  Lines        6190     6193       +3     
==========================================
- Hits         4311     4309       -2     
- Misses       1486     1491       +5     
  Partials      393      393              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 10, 2025
@tac0turtle tac0turtle added this pull request to the merge queue Jun 11, 2025
Merged via the queue into evstack:main with commit 619bd55 Jun 11, 2025
20 of 21 checks passed
@github-project-automation github-project-automation Bot moved this to Done in Evolve Jun 11, 2025
@adlerjohn adlerjohn deleted the adlerjohn/genesis-file-exists-error branch June 11, 2025 11:39
@tac0turtle tac0turtle removed this from Evolve Aug 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants